package javamusic.Servlet.Cliente;

import java.io.IOException;

import javamusic.negocio.GestionCliente;
import javamusic.negocio.GestionPersona;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class ServletClienteRegistrar
 */
@WebServlet("/ServletClienteRegistrar")
public class ServletClienteRegistrar extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ServletClienteRegistrar() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		// TODO Auto-generated method stub
		String dni1 = request.getParameter("dni");
		int dni = Integer.parseInt(dni1);
		String nombre = request.getParameter("nombres");
		String materno = request.getParameter("materno");
		String paterno = request.getParameter("paterno");
		
		String correo = request.getParameter("correo");
		String clave = request.getParameter("clave");
		String telefono1 = request.getParameter("telefono");
		int telefono = Integer.parseInt(telefono1);
		
		
		
		try {
			GestionPersona negocio = new GestionPersona();
			GestionCliente negocio1 = new GestionCliente();
			
			negocio.insertar(dni, nombre, paterno, materno);
			negocio1.insertar(correo,clave,telefono,dni);
			//request.setAttribute( negocio.insertar(idsala,nombre,capacidad,descripcion,elog,idlocal));
			//response.sendRedirect(request.getContextPath()	+ "/");
			RequestDispatcher rd = request.getRequestDispatcher("inicio.jsp");
			rd.forward(request, response);
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}
		
	}

}
